using UnityEngine;
using System.Collections;

public class EventChangeScene: MonoBehaviour {

	GUIButton button;
    public string m_LevelName = "";
    /// <summary>
    /// Indica si la escena donde esta este boton es ingame, asi llama al OnEndScene del game manager.
    /// </summary>
    public bool IsGameScene = true;
	void Start ()
	{
		button = gameObject.GetComponent<GUIButton>();
		button.OnClickCallback += OnClick;
		
		try{
			CharacterDataManager.GetInstance().LoadCharacters();
		}catch (System.Exception e){
			Debug.Log("NO EXISTE EL ARCHIVO DE SAVES");
			return;	
		}
	}
	void OnClick(Vector3 pos){
        if (IsGameScene)
        {
            GameManager.GetInstance().OnEndScene();
        }
		Application.LoadLevel(m_LevelName);
	}
}
